package com.boss.fileapp.dao.impl;

import com.boss.fileapp.consts.TableName;
import com.boss.fileapp.dao.IAgencyInfoDao;
import com.boss.framework.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

@Repository
public class AgencyInfoDaoImpl extends BaseDaoImpl implements IAgencyInfoDao {

    @Override
    public List<String> selectAgencyIdsByProvince(String province,String sendBankCode) {
        List<String> params=new ArrayList<>();
        StringBuilder sb = new StringBuilder();
        sb.append(" select DISTINCT pet.agency_id ")
                .append(" from ").append(TableName.PERSON_EXT_SUBMIT).append(" pet ")
                .append(" join ").append(TableName.AGENCY_VERIFY).append(" avy ")
                .append(" on ").append(" avy.agency_id = pet.agency_id and avy.is_deleted = 0 and avy.is_month_end = 0 ")
                .append(" and  is_pay_data_created = 1 ")
                .append(" where ").append("  pet.mof_div_code = ? ");
        params.add(province);
        if(!StringUtils.isEmpty(sendBankCode)){
            sb.append(" and pet.sala_card_bank=? ");
            params.add(sendBankCode);
        }
        return super.getjdbcTemplate().queryForList(sb.toString(), String.class, params.toArray());
    }

}
